﻿using System;
using System.Collections.Generic;
using Terraria.DataStructures;

namespace Terraria.Graphics.Shaders
{
	// Token: 0x0200038C RID: 908
	public class ArmorShaderDataSet
	{
		// Token: 0x06002014 RID: 8212 RVA: 0x0045B61C File Offset: 0x0045981C
		public T BindShader<T>(int itemId, T shaderData) where T : ArmorShaderData
		{
			Dictionary<int, int> shaderLookupDictionary = this._shaderLookupDictionary;
			int num = this._shaderDataCount + 1;
			this._shaderDataCount = num;
			shaderLookupDictionary[itemId] = num;
			this._shaderData.Add(shaderData);
			return shaderData;
		}

		// Token: 0x06002015 RID: 8213 RVA: 0x000167C2 File Offset: 0x000149C2
		public void Apply(int shaderId, Entity entity, DrawData? drawData = null)
		{
			if (shaderId != 0 && shaderId <= this._shaderDataCount)
			{
				this._shaderData[shaderId - 1].Apply(entity, drawData);
				return;
			}
			Main.pixelShader.CurrentTechnique.Passes[0].Apply();
		}

		// Token: 0x06002016 RID: 8214 RVA: 0x0045B658 File Offset: 0x00459858
		public void ApplySecondary(int shaderId, Entity entity, DrawData? drawData = null)
		{
			if (shaderId != 0 && shaderId <= this._shaderDataCount)
			{
				this._shaderData[shaderId - 1].GetSecondaryShader(entity).Apply(entity, drawData);
				return;
			}
			Main.pixelShader.CurrentTechnique.Passes[0].Apply();
		}

		// Token: 0x06002017 RID: 8215 RVA: 0x00016800 File Offset: 0x00014A00
		public ArmorShaderData GetShaderFromItemId(int type)
		{
			if (this._shaderLookupDictionary.ContainsKey(type))
			{
				return this._shaderData[this._shaderLookupDictionary[type] - 1];
			}
			return null;
		}

		// Token: 0x06002018 RID: 8216 RVA: 0x0001682B File Offset: 0x00014A2B
		public int GetShaderIdFromItemId(int type)
		{
			if (this._shaderLookupDictionary.ContainsKey(type))
			{
				return this._shaderLookupDictionary[type];
			}
			return 0;
		}

		// Token: 0x06002019 RID: 8217 RVA: 0x00016849 File Offset: 0x00014A49
		public ArmorShaderData GetSecondaryShader(int id, Player player)
		{
			if (id != 0 && id <= this._shaderDataCount && this._shaderData[id - 1] != null)
			{
				return this._shaderData[id - 1].GetSecondaryShader(player);
			}
			return null;
		}

		// Token: 0x04003CD7 RID: 15575
		protected List<ArmorShaderData> _shaderData = new List<ArmorShaderData>();

		// Token: 0x04003CD8 RID: 15576
		protected Dictionary<int, int> _shaderLookupDictionary = new Dictionary<int, int>();

		// Token: 0x04003CD9 RID: 15577
		protected int _shaderDataCount;
	}
}
